package com.qf.service.impl;

import com.qf.dao.RoleDao;
import com.qf.pojo.SysRole;
import com.qf.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author bss
 * @version V1.0
 * @Project maven
 * @Package com.qf.service.impl
 * @Description:
 * @Date 2022/10/10 20:42
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    RoleDao roleDao;

    @Override
    public Set<String> findRoleById(int id) {
        List<SysRole> list = roleDao.findRoleById(id);
        //collect(Collectors.toSet() 指定转换为Set集合
        //map： 映射， 把role对象映射为 String
        Set<String> set = list.stream().map((role) -> {
            return role.getName();
        }).collect(Collectors.toSet());
        return set;
    }
}
